﻿<UserControl x:Class="WickedFlame.VecDraw.Views.MenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:cmds="clr-namespace:WickedFlame.VecDraw.VecApp"
             xmlns:t="clr-namespace:WickedFlame.Core.Tools;assembly=VecDraw.Core">
    
    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/MainMenuTemplate.xaml" />
                <ResourceDictionary>
                    <Image x:Key="MenuIconNew" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.New.ico" Height="16" Width="16" />
                    <!--../Images/Document.ico-->
                    <Image x:Key="MenuIconUndo" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Undo.ico" Height="16" Width="16" />
                    <Image x:Key="MenuIconRedo" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Redo.ico" Height="16" Width="16" />
                    <Image x:Key="MenuIconSave" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Save.png" Height="16" Width="16" />
                    <!--../Images/Save.ico-->
                    <Image x:Key="MenuIconOpen" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Folder.Open.png" Height="16" Width="16" />
                    <!--../Images/Open.ico-->
                    <Image x:Key="MenuIconTools" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Tools.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconLayers" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Layers.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconColorPalete" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.PaintBucket.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconHistory" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.History.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconSaveAs" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.SaveAs.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconMinus" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Minus.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconPlus" Source="/VecDraw.Resources;component/Images/VecDraw.Icon.Plus.png" Height="16" Width="16" />
                    <Image x:Key="MenuIconMagnet" Source="../Images/Magnet.ico" Height="16" Width="16" />

                    <LinearGradientBrush x:Key="GradientHeaderBrush" StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Offset="0.0" Color="#505050" />
                        <GradientStop Offset="1.0" Color="#282828" />
                    </LinearGradientBrush>


                    <ControlTemplate x:Key="mainMenuItem" TargetType="{x:Type MenuItem}">
                        <Border Name="Border" Opacity="0.7">
                            <Border.Background>
                                <SolidColorBrush Color="#00585858" />
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <ContentControl FontSize="18" FontWeight="Heavy" VerticalAlignment="Center">
                                    <ContentPresenter x:Name="Content" TextElement.Foreground="#80FFFFFF" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,10,5" ContentSource="Header" RecognizesAccessKey="True" />
                                </ContentControl>
                                <Path Name="Arrow" Margin="4,0,15,0"  Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M -2.5 0 L 2.5 -4 L 2.5 4 Z" Fill="{TemplateBinding Foreground}">
                                    <!--M 0 4 L 5 0 L 5 8 Z-->
                                    <!--M 0 0 L 0 8 L 5 4 Z-->
                                    <!--Data="M 0 0 L 4 5 L 8 0 Z"-->
                                    <Path.RenderTransform>
                                        <RotateTransform Angle="0" />
                                    </Path.RenderTransform>
                                </Path>

                                <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                                    <Border Name="SubmenuBorder" CornerRadius="0,4,4,4" SnapsToDevicePixels="True" Background="#585858" >
                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                                    </Border>
                                </Popup>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>

                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFF" />
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" To="1"/>
                                            <!--<DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" To="-90" DecelerationRatio="1" />-->
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" />
                                            <!--<DoubleAnimation  Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" AccelerationRatio="1" />-->
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                            <Trigger Property="IsSuspendingPopupAnimation" Value="True">
                                <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSuspendingPopupAnimation" Value="True" />
                                    <Condition Property="IsHighlighted" Value="True" />
                                </MultiTrigger.Conditions>
                                <MultiTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" To="1"/>
                                            <DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" To="-90" DecelerationRatio="1" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.EnterActions>
                                <MultiTrigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" />
                                            <DoubleAnimation  Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" AccelerationRatio="1" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.ExitActions>

                                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFFFFFFF" />
                            </MultiTrigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>

    <Grid>
        <Menu Name="mainMenu" ToolBar.OverflowMode="Never" Background="Transparent">
            <MenuItem Header="VecDraw" Name="fileMenu" Template="{StaticResource mainMenuItem}">
                <!--
                <MenuItem Header="New" Command="cmds:MainMenuCustomCommands.NewCommand" Icon="{StaticResource MenuIconNew}" />
                <MenuItem Header="Open" Command="cmds:MainMenuCustomCommands.OpenCommand" Icon="{StaticResource MenuIconOpen}"/>
                <MenuItem Header="Save" Command="cmds:MainMenuCustomCommands.SaveCommand" Icon="{StaticResource MenuIconSave}"/>
                <MenuItem Header="Save As" Command="cmds:MainMenuCustomCommands.SaveAsCommand" Icon="{StaticResource MenuIconSaveAs}"/>-->
                <MenuItem Header="New" InputGestureText="Ctrl+N" Command="{Binding NewCommand}" Icon="{StaticResource MenuIconNew}" />
                <MenuItem Header="Open" InputGestureText="Ctrl+O" Command="{Binding OpenCommand}" Icon="{StaticResource MenuIconOpen}"/>
                <MenuItem Header="Save" InputGestureText="Ctrl+S" Command="{Binding SaveCommand}" Icon="{StaticResource MenuIconSave}"/>
                <MenuItem Header="Save As" InputGestureText="Ctrl+Shift+S" Command="{Binding SaveAsCommand}" Icon="{StaticResource MenuIconSaveAs}"/>
                <Separator />
                <MenuItem Header="Exit" Command="cmds:MainMenuCustomCommands.ExitCommand" />
            </MenuItem>

            <MenuItem Header="Edit">
                <MenuItem Header="Undo" InputGestureText="Ctrl+Z" Command="{Binding UndoCommand}" Icon="{StaticResource MenuIconUndo}"/>
                <MenuItem Header="Redo" InputGestureText="Ctrl+Y" Command="{Binding RedoCommand}" Icon="{StaticResource MenuIconRedo}"/>
                <Separator/>
                <MenuItem Header="Copy" InputGestureText="Ctrl+C" Command="{Binding CopyCommand}" />
                <MenuItem Header="Cut" InputGestureText="Ctrl+X" Command="{Binding CutCommand}" />
                <MenuItem Header="Paste" InputGestureText="Ctrl+V" Command="{Binding PasteCommand}" />
                <MenuItem Header="Delete" InputGestureText="Del" Command="{Binding DeleteCommand}"/>
                <Separator/>
                <MenuItem Header="Select All" InputGestureText="Ctrl+A" Command="{Binding SelectAllCommand}"/>
                <MenuItem Header="Unselect All" InputGestureText="Esc" Command="{Binding UnselectAllCommand}"/>                
            </MenuItem>

            <MenuItem Header="View">
                <MenuItem Header="Zoom In" InputGestureText="Ctrl++" Command="{Binding ZoomInCommand}" Icon="{StaticResource MenuIconPlus}" />
                <MenuItem Header="Zoom Out" InputGestureText="Ctrl+-"  Command="{Binding ZoomOutCommand}" Icon="{StaticResource MenuIconMinus}"/>
                <Separator/>
                <MenuItem Header="Show Grid" Command="{Binding ShowGridCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" IsCheckable="True" />
                <MenuItem Header="Snap to Grid" IsCheckable="True" Icon="{StaticResource MenuIconMagnet}" IsEnabled="False"/>
                <MenuItem Header="Snap to Trackers" Command="{Binding SnapToTrackerCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" IsCheckable="True" IsChecked="{Binding SnapToTrackers}"/><!--DataContext="{x:Static t:ShapePropertySettings.Settings}"-->
            </MenuItem>

            <MenuItem Header="Image">
                <MenuItem Header="Resize Canvas" IsEnabled="False"/>
            </MenuItem>

            <MenuItem Header="Layers">
                <MenuItem Header="Add Layer" Command="cmds:HistoryCommands.AddCommand" />
            </MenuItem>

            <MenuItem Header="Shape">
                <MenuItem Command="cmds:MainMenuCustomCommands.ToPolygonCommand" Name="mnuToPolygon" />
                <MenuItem Command="cmds:ShapeCommands.CombineShapesCommand"/>
                <MenuItem Command="cmds:ShapeCommands.CloseShape" />
                <MenuItem Header="Split line" IsEnabled="False"/>
                <MenuItem Header="Remove segment" IsEnabled="False"/>
                <Separator/>
                <MenuItem Command="cmds:MainMenuCustomCommands.CombineImagesCommand"/>
                <MenuItem Command="cmds:MainMenuCustomCommands.ToImageCommand"/>
                <Separator/>
                <MenuItem Header="Flip horizontal" IsEnabled="False"/>
                <MenuItem Header="Flip vertical" IsEnabled="False"/>
                <MenuItem Header="Rotate left" IsEnabled="False"/>
                <MenuItem Header="Rotate right" IsEnabled="False"/>
            </MenuItem>

            <!--<MenuItem Header="Window">
                <MenuItem Header="Tools"  Icon="{StaticResource MenuIconTools}"/>
                <MenuItem Header="Layers"  Icon="{StaticResource MenuIconLayers}"/>
                <MenuItem Header="Color palete" Name="mnuColorPallete"  Icon="{StaticResource MenuIconColorPalete}"/>
                <MenuItem Header="History" Name="mnuHistory"  Icon="{StaticResource MenuIconHistory}"/>
            </MenuItem>-->
        </Menu>
    </Grid>
</UserControl>
